// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import FastClick from 'fastclick'
//路由
import VueRouter from 'vue-router'
import App from './App'
import VueResource from 'vue-resource'


//引入css 会直接导入到页面（也是打包到js）
//在head  标签追加的style标签
import '../static/font-awesome-4.7.0/css/font-awesome.css'

//使用插件
Vue.use(VueResource)


// 图片地址过滤器
Vue.filter('isSrc', function (imghash) {
  if (!imghash) {
    return "";
  }
  var s1 = imghash.slice(0, 1);
  var s2 = imghash.slice(1, 3);
  var s3 = imghash.slice(3);
  var s4 = imghash.slice(32);
  return "http://fuss10.elemecdn.com/" + s1 + "/" + s2 + "/" + s3 + "." + s4;
})


// import '../static/Font-Awesome字体图标/css/font-awesome.css'
//模板例子
// import Home from './components/HelloFromVux'
import Home from './page/Home.vue'
import HomeList from './page/HomeList.vue'
import Shop from './page/Shop.vue'
import Ping from './page/Ping.vue'




Vue.use(VueRouter)
//路由规则
const routes = [
  {
    path: '/',
    component: Home
  },
  {
    path: '/home',
    component: Home
  },
  {
    path: '/home/list/:id',
    component: HomeList
  },
  {
    path: '/home/list/:id/shop',
    component: Shop
  },
  {
    path: '/home/list/:id/ping',
    component: Ping
  },
  
]
//创建路由
const router = new VueRouter({
  routes
})

//指定默认跳转的路由
// router.push('/home')


FastClick.attach(document.body)

Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  //指定路由
  router,
  render: h => h(App)
  //$el  和mount差不多  挂载点
}).$mount('#app-box')

//改变html字体大小
function calcRem(){
    var html = document.querySelector("html")
    var w = document.documentElement.clientWidth;
    //让页面字体大小为20
    //字体大小设置为12 以下，有些浏览器会转为12px；必须大于12
    //这是320的效果图
    html.style.fontSize = w/23.45 +  'px'
}
calcRem()
window.onresize = function(){
  calcRem()
}